package com.healthcare.apm.category.tool;

import lombok.Setter;

import javax.sql.DataSource;
import java.sql.*;

public class JDBCCategoryTools {

    @Setter
    private DataSource dataSource;

    public JDBCCategoryTools(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    public void excuteSql(String sql) {
        System.out.println("Excute sql: " + sql);
        try (Connection conn = dataSource.getConnection()) {
            try (Statement st = conn.createStatement()) {
                st.execute(sql);
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }



}
